#include "../../include/car_parts/agx.h"

AGX::AGX()
{
    this->model = "AGX Xavier";
    this->aiPerformance = 32;
    this->cudaCores = 512;
    this->tensorCores = 64;
    this->memory = 32;
    this->storage = 32;
}

void AGX::setModel(const std::string &model)
{
    this->model = model;
}

void AGX::setAiPerformance(int aiPerformance)
{
    this->aiPerformance = aiPerformance;
}

void AGX::setCudaCores(int cudaCores)
{
    this->cudaCores = cudaCores;
}

void AGX::setTensorCores(int tensorCores)
{
    this->tensorCores = tensorCores;
}

void AGX::setMemory(int memory)
{
    this->memory = memory;
}

void AGX::setStorage(int storage)
{
    this->storage = storage;
}

// 屏幕输出
void AGX::print()
{
    std::cout << "**AGX模块**"
              << "\nAI(TOPS): " << aiPerformance
              << "\nCUDA核心: " << cudaCores << "\n显存(GB): " << memory << "\nAGX型号: " << model << "\n存储(GB): " << storage << "\nTensor CORE: " << tensorCores << std::endl;
}
// 本地文件保存
void AGX::save(const std::string &filename)
{
    // 打开一个输出文件流
    std::ofstream file(filename, std::ios::app);
    if (!file.is_open())
    {
        std::cout << "未找到文件！" << std::endl;
        return;
    }

    file << "," << aiPerformance
         << "," << cudaCores << "," << memory << "," << model << "," << storage << "," << tensorCores;

    // 关闭文件流
    file.close();
}